<include file="Public/head"/>
<script src="{:get_style_cdnurl()}paimai/yunying/js/city.js" type="text/javascript"></script>
<link type="text/css" rel="stylesheet" href="{:get_style_cdnurl()}paimai/yunying/css/cashier.css"/>
<style type="text/css">
    #is_expert, #is_recommend_expert {
        -moz-appearance: none;
        background: rgba(0, 0, 0, 0) url("{:get_style_cdnurl()}paimai/yunying/images/sanjiao.jpg") no-repeat scroll 130px 5px;
        border: 1px solid #d7d7d7;
        color: #666;
        font-family: "微软雅黑";
        height: 26px;
        line-height: 26px;
        text-align: left;
        width: 154px;
    }
</style>
</head>
<include file="Public/common_header"/>
<div class="mian">
    <include file="Public/sidebar" menu='zhgl.grzh'/>
    <div class="mianR">
        <div class="yuyue">
            <ul>
                <li data-id="0" class="yuCurrent">基本信息</li>
                <li data-id="1">成长值</li>
                <li data-id="2">积分</li>
                <li data-id="3">钱包</li>
                <li data-id="4">爱车</li>
            </ul>
        </div>
        <div class="live-seach" style="display: none;">
            <ul class="clearfix receivables">
                <li>
                    <input type="text" name="start_time" placeholder="开始时间" value="" class="xiaci1 xin-text"
                           id="start_time" readonly>
                </li>
                <li>
                    <input type="text" name="end_time" placeholder="结束时间" value="" class="xiaci1 xin-text" id="end_time"
                           readonly/>
                </li>
                <li class="collection">
                    <input type="button" onclick="user_search($('#status').val())" value="搜索">
                </li>
            </ul>
        </div>
        <div class='listBox'>
            <div class="yuList">
                <div class="account-text">
                    <dl>
                        <dt>
                            <if condition="$clcw_user_info.avatar eq ''">
                                <img src="{:get_style_cdnurl()}paimai/yunying/images/carded_ico.jpg"/>
                                <else/>
                                <img src="{$clcw_user_info.avatar}"/>
                            </if>
                        </dt>
                        <dd>
                            <table class="receivables-cont">
                                <tbody>
                                <tr>
                                    <td width="30%">个人ID</td>
                                    <td width="70%">{$clcw_user_info.user_id}</td>
                                </tr>
                                <tr>
                                    <td>姓名</td>
                                    <td>{$clcw_user_info.real_name}</td>
                                </tr>
                                <tr>
                                    <td>用户等级</td>
                                    <td>{$clcw_user_info.user_level}</td>
                                </tr>
                                <tr>
                                    <td>等级变更时间</td>
                                    <td>{$clcw_user_info.change_level_time}</td>
                                </tr>
                                <tr>
                                    <td>账号</td>
                                    <td>{$clcw_user_info.nick_name}</td>
                                </tr>
                                <tr>
                                    <td>手机号</td>
                                    <td>{$clcw_user_info.mobile}</td>
                                </tr>
                                <!--<if condition="$clcw_user_info.is_expert eq 1">-->
                                <!--<tr>-->
                                <!--<td>擅长品牌</td>-->
                                <!--<td>{$clcw_user_info.good_brand}</td>-->
                                <!--</tr>-->
                                <!--</if>-->
                                <tr>
                                    <td>创建时间</td>
                                    <td>{$clcw_user_info.create_time}</td>
                                </tr>
                                </tbody>
                            </table>
                        </dd>

                        <dd>
                            <table class="receivables-cont receivables-cont1">
                                <tbody>
                                <tr>
                                    <td class="be-width">是否牛人</td>
                                    <td width="70%">
                                        <select name="is_expert" id="is_expert" class="be-something">
                                            <option value="0">请选择是否牛人</option>
                                            <option value="1" <?php echo $clcw_user_info['is_expert'] == 1?'selected':'' ?>>是</option>
                                            <option value="2" <?php echo $clcw_user_info['is_expert'] == 0?'selected':'' ?>>否</option>
                                        </select>
                                    </td>
                                </tr>
                                <if condition="$clcw_user_info.is_expert eq 1">
                                    <tr>
                                        <td>设置牛人时间</td>
                                        <td>{$clcw_user_info.change_expert_time}</td>
                                    </tr>
                                </if>
                                <tr>
                                    <td>是否推荐牛人</td>
                                    <td>
                                        <select name="is_recommend_expert" id="is_recommend_expert"
                                                class="be-something">
                                            <option value="0">请选择是否推荐牛人</option>
                                            <option value="1" <?php echo $clcw_user_info['is_top'] == 1?'selected':'' ?>>是</option>
                                            <option value="2" <?php echo $clcw_user_info['is_top'] == 0?'selected':'' ?>>否</option>
                                        </select>
                                    </td>
                                </tr>
                                <tr>
                                    <td>擅长品牌</td>
                                    <td style="position: relative;">
                                        <div class="good-brand-btn">
                                            <?php foreach($clcw_user_info['expert_brand_list'] as $k=>$v){echo "<span
                                                data-id='".$k."'>".$v."<i>×</i></span>";}?>
                                            <foreach name="$clcw_user_info.expert_brand_list" item="vo">
                                                {$vo}
                                            </foreach>
                                            <input type="hidden" value="{$clcw_user_info.expert_brand}"
                                                   name="good_brand" id="good_brand"/>
                                        </div>
                                        <div class="cattle clearfix">
                                            <script src="{:get_style_cdnurl()}paimai/cheshan/js/model_select.js"
                                                    type="text/javascript"></script>
                                        </div>
                                        <script>
                                            ModelSelect.not_allow_model = true; //不使用车型
                                            ModelSelect.not_allow_serires = true; //不使用车系
                                            $(".cattle span").hide();
                                            $(".chexing").css("width", "180px");
                                            $(".cattle").css({
                                                "width": "180px",
                                                "padding": 0,
                                                "float": "left"
                                            })

                                            $(function () {
                                                var arr = new Array();
                                                $(".good-brand-btn span").each(function () {
                                                    arr.push($(this).attr("data-id"));
                                                });
                                                if (arr.length >= 3) {
                                                    $('.cattle').hide();
                                                }
                                                $(".paiText dl").on("click", "dd", function () {
                                                    var oText = $(this).html();
                                                    var oAttr = $(this).attr("brand_id");
                                                    var html = "<span data-id=" + oAttr + ">" + oText + "<i>×</i></span>";
                                                    if (oAttr == 00) {
                                                        return false;
                                                    }
                                                    if (arr.indexOf(oAttr) != -1) {
                                                        shibai_alert('抱歉，您添加的品牌已存在');
                                                        return false;
                                                    }
                                                    arr.push(oAttr);
                                                    if (arr.length > 2) {
                                                        $('.cattle').hide();
                                                    }
                                                    $(".good-brand-btn input").attr("value", arr);
                                                    $(".good-brand-btn").append(html);
                                                    if ($(".good-brand-btn span").length > 0) {
                                                        $(".cattle").css({
                                                            "width": "180px",
                                                            "padding": 0,
                                                            "float": "left",
                                                            "marginLeft": "0",
                                                            "position": "relative",
                                                            "z-index": 0
                                                        })
                                                    }
                                                })
                                                $(".good-brand-btn").on("click", "i", function () {
                                                    var iAttr = $(this).parent().attr("data-id");
                                                    $(this).parent().remove();
                                                    arr.splice($.inArray(iAttr, arr), 1);
                                                    if (arr.length < 3) {
                                                        $('.cattle').show();
                                                    }
                                                    $(".good-brand-btn input").attr("value", arr);
                                                    if ($(".good-brand-btn span").length == 0) {
                                                        $(".cattle").css({
                                                            "width": "180px",
                                                            "padding": 0,
                                                            "float": "left",
                                                            "marginLeft": "200px"
                                                        })
                                                    }
                                                });

                                                var is_expert = $("#is_expert").find("option:selected").val();
                                                if (is_expert == 2) {
                                                    $(".receivables-cont1 tr").not(":first").hide();
                                                    $('.expert-introduction').hide();
                                                }
                                                $("#is_expert").on("change", function () {
                                                    var oText = $(this).find("option:selected").val();
                                                    if (oText == 2) {
                                                        $(".receivables-cont1 tr").not(":first").hide();
                                                        $('.expert-introduction').hide();
                                                    } else {
                                                        $(".receivables-cont1 tr").show();
                                                        $('.expert-introduction').show();
                                                    }
                                                })
                                            })
                                        </script>

                                    </td>
                                </tr>
                                <tr>
                                    <td>擅长类型</td>
                                    <td>
                                        <div class="excel_type">
                                            <volist name="category_list" id="cl">
                                                <?php if(in_array($cl['id'], explode(',',$clcw_user_info['expert_category']))): ?>
                                                <input id="{$cl.id}" type="button" value="{$cl.category_name}" class="current">
                                                <?php else: ?>
                                                <input id="{$cl.id}" type="button" value="{$cl.category_name}">
                                                <?php endif; ?>
                                            </volist>
                                        </div>
                                        <input id="excelhide" type="hidden" value="{$clcw_user_info.expert_category}">
                                    </td>
                                </tr>
                                <script type="text/javascript">
                                    var excelArr=[];
                                    if($("#excelhide").attr("value")!=""){
                                        excelArr = $("#excelhide").attr("value").split(',');
                                    }
                                    $(".excel_type input").on("click",function(i){
                                        var oId=$(this).attr("id");
                                        if($(this).hasClass('current')){
                                            $(this).removeClass("current");
                                            var resultArr = $.map(excelArr,function(item){
                                                if(item==oId){
                                                    item = null;
                                                }
                                                return item;
                                            });
                                            excelArr = resultArr;
                                            console.log(excelArr)
                                            $("#excelhide").attr("value",excelArr);
                                        }else{
                                            excelArr.push(oId);
                                            $(this).addClass('current');
                                            $("#excelhide").attr("value",excelArr);
                                        }
                                    })
                                </script>
                                </tbody>
                            </table>
                        </dd>
                    </dl>
                    <div class="expert-introduction">
                        <span>牛人介绍</span>
                        <textarea class="cattle-ren">{$clcw_user_info.user_intro}</textarea>
                    </div>
                </div>
            </div>
            <div class='yuList' style='display:none'>
                <div class="growth-value">
                    <div class="xinxi-conter clearfix">
                        <h4 class="order_no">总成长值：<b>{$clcw_user_info.user_exp}</b></h4>
                    </div>
                </div>
                <div id="growth-list"></div>
            </div>
            <div class='yuList' style='display:none'>
                <div class="growth-value">
                    <div class="xinxi-conter clearfix">
                        <h4 class="order_no">总积分：<b>{$clcw_user_info.user_score}</b></h4>
                    </div>
                </div>
                <div id="score-list"></div>
            </div>
            <div class='yuList' style='display:none'>
                <div class="growth-value">
                    <div class="xinxi-conter clearfix">
                        <h4 class="order_no">总金额：<b>{$clcw_user_info.user_money|default=0}</b></h4>
                    </div>
                </div>
                <div id="wallet-list"></div>
            </div>
            <div class='yuList' style='display:none'>
                <div class="car-list-cont clearfix">
                    <empty name="my_car_list">
                        您还没有添加爱车！
                        <else/>
                        <volist name="my_car_list" id="mcl" key="k">
                            <dl>
                                <dt>爱车{$k}</dt>
                                <dd>
                                    <ul>
                                        <li><span>归属城市：</span>{$mcl.location_area}</li>
                                        <li><span>发动机号：</span>{$mcl.engine_number}</li>
                                        <li><span>车牌号码：</span>{$mcl.plate_number}</li>
                                        <li><span>车架号：</span>{$mcl.frame_number}</li>
                                    </ul>
                                </dd>
                            </dl>
                        </volist>
                    </empty>
                </div>
            </div>
        </div>
        <div class="yongBtn">
            <input type="hidden" name="uid" id="uid" value="{$clcw_user_info.user_id}"/>
            <input type="hidden" name="status" id="status" value=""/>
            <input type="button" value="确定" class="queding"/>
            <input type="button" class="quxiao" onclick="history.go(-1);" value="取消"/>
        </div>
    </div>
</div>
</div>

<div class="clear"></div>
</div>
<script type="text/javascript">
    $(function () {
        $("#is_recommend_expert").css("color", "#000");
        $("#is_recommend_expert").find("option").css("color", "#000");
        $("#is_recommend_expert").each(function () {
            $(this).change(function () {
                var selectIndex = $(this).get(0).selectedIndex;
                if (selectIndex == 0) {
                    $(this).css("color", "#000");
                    $(this).find("option").css("color", "#000");
                } else {
                    $(this).css("color", "#000");
                }
            })
        });
    })

    $(function () {
        $(".yuyue ul li").click(function () {
            $(".live-seach").show();
            clear_form_params();
            var status = $(this).attr('data-id');
            $("#status").val(status);
            get_list(status);
        });
        $(".yuyue ul li:first-child,.yuyue ul li:last-child").click(function () {
            $(".live-seach").hide();
        });

        $("#start_time").ymdateplugin({});
        $("#end_time").ymdateplugin({});
    });
    //获取url中的参数
    function getUrlParam(name) {
        var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)"); //构造一个含有目标参数的正则表达式对象
        var r = window.location.search.substr(1).match(reg);  //匹配目标参数
        if (r != null)
            return unescape(r[2]);
        return null; //返回参数值
    }
    function get_list(t) {
        var url = mkUrl();
        var p = getUrlParam('p');
        if (p != null) {
            var purl = "?p=" + p;
        } else {
            var purl = "?p=1";
        }
        var action = '';
        var listBox = '';
        if (t == 1) {
            action = '/ClcwUser/userGrowthList';
            listBox = "growth-list";
        } else if (t == 2) {
            action = '/ClcwUser/userScoreList';
            listBox = "score-list";
        } else if (t == 3) {
            action = '/ClcwUser/userWalletList';
            listBox = "wallet-list";
        }
        $.get(action + purl, url, function (data) {
            $("#" + listBox).html(data);
        }, "html");
    }
    function user_search(t) {
        get_list(t);
    }
    function get_page(p) {
        var url = mkUrl();
        var t = $('#status').val();
        var action = '';
        var listBox = '';
        if (t == 1) {
            action = '/ClcwUser/userGrowthList';
            listBox = "growth-list";
        } else if (t == 2) {
            action = '/ClcwUser/userScoreList';
            listBox = "score-list";
        } else if (t == 3) {
            action = '/ClcwUser/userWalletList';
            listBox = "wallet-list";
        }
        $.get(action + encodeURI("/p/" + p), url, function (data) {
            $("#" + listBox).html(data);
        }, "html");
    }
    function mkUrl() {
        var url = "";
        var uid = "{$clcw_user_info.user_id}"
        var start_time = $("input[name='start_time']").val();
        var end_time = $("input[name='end_time']").val();
        if (uid) {
            url += '&uid=' + uid;
        }
        if (start_time) {
            url += '&start_time=' + start_time;
        }
        if (end_time) {
            url += '&end_time=' + end_time;
        }
        return url;
    }
    function clear_form_params() {
        $(':input').not(':button, :submit, :reset, :hidden, select').val('');
    }

    $(".queding").click(function () {
        var uid = $('#uid').val();
        var isExpert = $('#is_expert').val();
        var isRecommendExpert = $('#is_recommend_expert').val();
        var goodBrand = $('#good_brand').val();
        var expertIntro = $('.cattle-ren').val();
        var expertGoodCategory = $('#excelhide').val();
//        if(expertGoodCategory == ''){
//            shibai_alert('抱歉，请选择擅长类型');
//            return false;
//        }
        if (isExpert == 1 && expertIntro == '') {
            shibai_alert('抱歉，牛人介绍不能为空');
            return false;
        }
        var params = {
            'uid': uid,
            "is_expert": isExpert,
            "is_recommend_expert": isRecommendExpert,
            "good_brand": goodBrand,
            'good_category': expertGoodCategory,
            "expert_intro": expertIntro
        }
//        alert(isExpert+"="+isRecommendExpert+"="+expertIntro+"="+goodBrand);return;
        $.post("/ClcwUser/clcwUserEditData", params, function (res) {
            if (res.code == 200) {
                btn_alert(res.msg);
                setTimeout(function () {
                    window.location.href = "/ClcwUser/index";
                }, 2000);
            } else {
                shibai_alert(res.msg);
            }
        }, 'json');
    });

</script>
<include file="Public/foot"/>